/**
 * 功能描述
 */
define(function (require, exports, module) {
    //引入视图基类
    var ELView = require("elview");

    //assets
    var template = require("./assets/tpl/roomtypeincome_main.tpl");
    require("./assets/css/roomtypeincome_main.css");

    //business

    //component
    var incomeSubnavComp = require("./component/roomtypeIncomeSubnavComp");
    var incomeGridComp = require("./component/roomtypeIncomeGridComp");
    var incomeDetailGridComp = require("./component/typeIncomeDetailGridComp");

    //constant

    //handler

    //store

    var App = ELView.extend({
        attrs: {
            template: template
        },
        initComponent: function (params, widget) {
        	incomeSubnavComp.initComponent(params, widget);
        	incomeGridComp.initComponent(params, widget);
        	incomeDetailGridComp.initComponent(params, widget);

        },
        afterInitComponent: function (params, widget) {
        	widget.get("grid").refresh(null,function(datas){
        		var k = 0;
        		for(var i in datas){
        			k+=(datas[i].incoming == null ? 0 : datas[i].incoming);
        		}
        		var j = parseFloat(k).toFixed(2);
        		widget.get("grid").setTitle("收入合计:" + j + "元");
        	})
        	
        	
//        	widget.get("detailgrid").refresh(null,function(data2){
//        		var j = 0;
//        		for(var i in data2){
//        			j+=(data2[i].allPay == null ? 0 : data2[i].allPay);
//        		}
//        		widget.get("detailgrid").setTitle("收入总金额:" +j);
//        	})
      }
    });

    module.exports = App;
});
